package org.mattmckay.PDFd.Layer;

import PDFd.Layer.DrawingUtilities.TouchInputAverager;
import junit.framework.TestCase;

public class TouchInputAveragerTest extends TestCase {
	TouchInputAverager tia;
	
	protected void setUp() throws Exception {
		super.setUp();
		tia = new TouchInputAverager(10);
	}

	protected void tearDown() throws Exception {
		super.tearDown();
	}
	public final void testCheckDivideByZero() {
		tia.scaleInput(0);
	}
	public final void testReset() {
		tia.scaleInput(1);
		tia.scaleInput(2);
		tia.reset();
		tia.scaleInput(0);
		assertEquals(tia.scaleInput(10),5,.1e-10);
	}

	public final void testScaleInput() {
		tia.reset();
		tia.scaleInput(.1f);
		tia.scaleInput(.1f);
		tia.scaleInput(.6f);
		tia.scaleInput(.7f);
		tia.scaleInput(.2f);
		tia.scaleInput(.9f);
		tia.scaleInput(.9f);
		tia.scaleInput(.9f);
		tia.scaleInput(.9f);
		//Since we're at 10 inputs, we start droping the first couple inputs
		tia.scaleInput(.9f);
		assertEquals(tia.scaleInput(.1f),.6777778267860413,.1e-10);
	}

}
